#ifndef WF_PLACE_H
#define WF_PLACE_H

#include "types/colorset.h"
#include "types/multiset.h"
#include "types/timedmultiset.h"

#include <inodedata.h>
#include <iplace.h>
#include <node.h>

#include <QtCore/QObject>

using namespace core;
using namespace net;

namespace wfnet
{
class Transition;
class WfNet;

class Place : public QObject, /*implements*/public IPlace, public INodeData
{
    Q_OBJECT

public:    
    ~Place();

    // IIdentifiable
    nid getId() const;

    // IPlace
    QString name() const;

    const IColorSet* getColorSet() const;

    const IMultiset* getTokens() const;
    void putTokens(IMultiset* tokens);
    void withdrawTokens(IMultiset* tokens);

    QSet<const ITransition* > getInputTransitions() const;
    QSet<const ITransition* > getOutputTransitions() const;

    // INodeData
    void registerNode(Node* node);
    const Node* const node() const;

protected:
    Place(WfNet* parent, nid id, QString name,
        IColorSet* colorSet);

private:
    void clearTokens();

private:
    friend class WfNet;
    friend class Transition;

    core::Node* m_node; // guarded pointer
    nid m_id;
    QString m_name;
    ColorSet m_colorSet;
    Multiset m_untimedTokens;
    TimedMultiset m_timedTokens;
};

} // namespace wfnet

#endif
